package com.kaifamiao.www.demo.do0824;

import java.time.Instant;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.util.Date;

public class Demo {
    public static void main(String[] args) {

//        System.out.println(System.currentTimeMillis());
//        System.out.println(System.nanoTime());
        /*
        java.util.Date表示特定的时间瞬间
         */
        Date date = new Date();
        System.out.println(date);
        System.out.println(date.getYear());
        System.out.println(date.getMonth());
        System.out.println(date.getDay()); //day of week
        System.out.println(date.getDate() );//day of month
        System.out.println(date.getHours());
        System.out.println(date.getMinutes());
        System.out.println(date.getSeconds());

        Date date1 = new Date(122,7,32);
        System.out.println(date1);

        Date date2 = new Date(1000L * 60 * 60 * 24 *365 * 52 + 1000L * 60 * 60 * 24 * 30 * 8);
        System.out.println(date2);

        System.out.println(date.after(date2));
        System.out.println(date.before(date2));

        System.out.println(date);

        System.out.println(date.toLocaleString());
        System.out.println(date.toGMTString());

        Instant instant = date.toInstant();
        //获取当前时间的毫秒值
        System.out.println(instant.get(ChronoField.MICRO_OF_SECOND));
       //将时间往前推几天
        System.out.println(instant.minus(-1L, ChronoUnit.DAYS));

        Instant now = Instant.now();
        System.out.println(now);
        System.out.println(Instant.parse("2007-12-03T10:15:32.00Z"));

    }
}
